﻿    <%@ Control Language="VB" AutoEventWireup="false" CodeFile="List.ascx.vb" Inherits="Control_MSDS_List" %>
<script type='text/javascript'>
	function ajaxJqueryMSDS() {

	    $(function () {
	        $('.btnChangeType').click(function () {
	            if ($('.GridBorder td input:checkbox').is(':checked')) {
	                return true;
	            }
	            else {
	                Alertbox("Bạn phải chọn ít nhất một bản ghi");
	                return false;
	            }
	        });
			//check cookie to show or hide search pannel
			//for enter search
			$(".Date").datepicker({ dateFormat: 'dd/mm/yy' });
			$(".SubjectTitle input, .SubjectTitle select").keypress(function (e) {
				if (e.keyCode == 13) {
					$("#<%=btnSearch.ClientID()%>").click();
					return false;
				}
			});
//	            alert($("#<%=hidIsUser.ClientID()%>").val());
//	            if ($("#<%=hidIsUser.ClientID()%>").val() != 1) {
//	                $(".AdminDuyet").attr("style","display:none");
//	            }
			if ($.cookie('CookieSiteSearch') == 1) {
				$('#pnlSearch').show();
			}
			else {
				$('#pnlSearch').hide();
			}

			$('#B1').click(function (event) {

				//set cookie
				if ($.cookie('CookieSiteSearch') == 1) {
					$.cookie('CookieSiteSearch', 0)
				}
				else {
					$.cookie('CookieSiteSearch', 1)
				}
				$('#pnlSearch').slideToggle(500);

				if ($('#imgShowHide').attr("src") == "../../images/arrow_popup.gif") {

					$('#imgShowHide').attr("src", "../../images/arrow_showless.gif");
				}
				else {
					$('#imgShowHide').attr("src", "../../images/arrow_popup.gif");
				}
			});

		});
	}


	function confirmMultiDelete(strID) {
		var grdShow = document.getElementById("<%=grdShow.ClientID %>");
			var count = 0;
			for (i = 1; i < grdShow.children.item(0).children.length; i++) {
				if (grdShow.children.item(0).children.item(i).children.item(0).children.item(0).checked) {
					count += 1;
				}
			}
			if (count > 0) {
				return ComfirmDialog('<%=drpMessage.Items(1).Text%>', 0, strID, 0, 0);
	    	} else {
	    		Alertbox('<%=drpMessage.Items(2).Text%>');
	    		return false;
	    	}
		}
	function ComfirmDialog(strText, value, ObjectIdClick, ID, Type) {
			if (value == 0) {
				Confirmbox(strText, value, ObjectIdClick, ID, Type);
				return false;
			} else {
				if (Type == 1) {
					document.getElementById('<%=hidID.ClientID %>').value = ID;
					eval($("#" + ObjectIdClick + "").attr("href"));
				}
				else {
					$("#" + ObjectIdClick + "").click();
				}
			}
		}
		function SetValue(id) {
			document.getElementById('<%=hidID.ClientID %>').value = id;
		}
		function SetDownFile(aURL) {
		    if (aURL.indexOf(".pdf") > -1) {
		        open_window_max(aURL, 'pdf');
            }
		    document.getElementById('expFile').src = aURL;
		    return false;
		}


		function writeSwf(swf) {
		    open_window_max('../PrintLabel/Viewer.aspx?swf=' + swf, 'viewer');
		}



		function open_window_max(aURL, aWinName) {
		    var wOpen;
		    var sOptions;

		    sOptions = 'status=no,menubar=no,scrollbars=auto,resizable=no,toolbar=no,fullscreen=yes';
		    sOptions = sOptions + ',width=' + (screen.availWidth - 0).toString();
		    sOptions = sOptions + ',height=' + (screen.availHeight - 0).toString();
		    sOptions = sOptions + ',screenX=0,screenY=0,left=0,top=0';

		    wOpen = window.open('', aWinName, sOptions);
		    wOpen.location = aURL;
		    wOpen.focus();
		    wOpen.moveTo(0, 0);
		    wOpen.resizeTo(screen.availWidth, screen.availHeight);
		    return wOpen;
		}

</script>


<asp:UpdatePanel ID="uplMsdssection01" runat="server">
	<ContentTemplate>
		<div class="BoxField">
			<div class="HeadTitle">
				<h3>QUẢN LÝ MSDS</h3>

			</div>
		</div>
		<legend>
			<img alt="" src="../../images/arrow_showless.gif" id="imgShowHide" />
			<a id="B1" href="#">Tìm </a>&nbsp;&nbsp;</legend>
		<div id="pnlSearch" class="SubjectTitle">
			<div id="search" class="BoxField">
				<div class="DivRow">
					<div class="DivLabelSearch">
						Item Code:
					</div>
					<div class="DivTextBox">
						<asp:TextBox ID="txtItemcode" CssClass="TextBox" runat="server" Text="" />
					</div>
				</div>
				<div style="clear: both">
				</div>
				<div class="DivRow">
					<div class="DivLabelSearch">
						Item Description:
					</div>
					<div class="DivTextBox">
						<asp:TextBox ID="txtItemname" CssClass="TextBox" runat="server" Text="" />
					</div>
				</div>
				<div style="clear: both">
				</div>
				<div class="DivRow">
					<div class="DivLabelSearch">
						Vendor Code:
					</div>
					<div class="DivTextBox">
						<asp:TextBox ID="txtVendorcode" CssClass="TextBox" runat="server" Text="" />
					</div>
				</div>
				<div style="clear: both">
				</div>
				<div class="DivRow">
					<div class="DivLabelSearch">
						Vendor Name:
					</div>
					<div class="DivTextBox">
						<asp:TextBox ID="txtVendorname" CssClass="TextBox" runat="server" Text="" />
					</div>
				</div>
				<div style="clear: both">
				</div>
				<div class="DivRow">
					<div class="DivLabelSearch">
						Created:
					</div>
					<div class="DivTextBox">
						<asp:TextBox ID="txtCreatedFrom" CssClass="TextBox Date" Width="85px" runat="server"
							Text="" />
						to:
						<asp:TextBox ID="txtCreatedTo" CssClass="TextBox Date" Width="85px" runat="server"
							Text="" />
					</div>
				</div>
				<div style="clear: both">
				</div>
				<div class="DivRow">
					<div class="DivLabelSearch">
						Status:
					</div>
					<div class="DivTextBox">
						<asp:DropDownList ID="ddlStatusId" CssClass="DropDownList" runat="server">
						</asp:DropDownList>
					</div>
				</div>
				<div style="clear: both">
				</div>
				<div class="DivRow">
					<div class="DivLabelSearch">
						CAS:
					</div>
					<div class="DivTextBox">
                    <asp:TextBox ID="txtCAS" CssClass="TextBox" runat="server" Text="" />                        
					</div>
				</div>
				<div style="clear: both">
				</div>

				<div class="DivRow">
					<div class="DivLabelSearch">
						Sort By:
					</div>
					<div class="DivTextBox">
						<asp:DropDownList ID="ddlFieldSort" CssClass="DropDownList" runat="server">
						</asp:DropDownList>                                          
					</div>
				</div>
				<div style="clear: both">
				</div>

				<div class="DivRow">
					<div class="DivLabelSearch">
						&nbsp;&nbsp;&nbsp;
					</div>
					<div class="DivTextBox">
						<asp:Button ID="btnSearch" runat="server" Text=" Tìm " CssClass="btn" />
						<asp:Button ID="btnReset" runat="server" Text="Làm mới" CssClass="btn" />&nbsp;
					</div>
				</div>
				<div style="clear: both; height: 10px">
				</div>
			</div>
		</div>
		<div style="clear: both; height: 10px">
		</div>
		<asp:GridView ID="grdShow" runat="server" AutoGenerateColumns="False" EmptyDataText="{Không có dữ liệu}"
			AllowPaging="false" Width='100%' BorderWidth="1px" CssClass="GridBorder">
			<Columns>
				<asp:TemplateField>
					<HeaderTemplate>
						<asp:CheckBox ID="CheckAll" runat="server" onclick="CheckAll(this);" Width="30px" />
					</HeaderTemplate>
					<HeaderStyle HorizontalAlign="Center" />
					<ItemTemplate>
						<asp:CheckBox ID="chkItem" runat="server" />
					</ItemTemplate>
					<ItemStyle Width="5%" HorizontalAlign="Center" />
				</asp:TemplateField>
	            <asp:TemplateField HeaderText="STT">
		              <ItemTemplate>
			                <asp:Label runat="server" ID="lblSTT" Text='STT'></asp:Label>
	             </ItemTemplate>
		              <ItemStyle Width="3%"  HorizontalAlign="Left" />
	            </asp:TemplateField>
				<asp:TemplateField>

					<ItemTemplate>
						<asp:HyperLink ID="hplEdit" runat="server" Text="Sửa"></asp:HyperLink>&nbsp;|&nbsp;
						<asp:LinkButton ID="lnkbtnDelete" Text="Xóa" runat="server" OnClick="lnkbtnDelete_Click"
							CausesValidation='False'></asp:LinkButton>
					</ItemTemplate>
					<ItemStyle CssClass="GridTextLink" HorizontalAlign="Center" Width="7%" />
				</asp:TemplateField>
				<asp:BoundField DataField='ItemCode' HeaderText='Item Code'>
					<ItemStyle Width='7%' />
				</asp:BoundField>
				<asp:TemplateField HeaderText='Item Name'>
					<ItemTemplate>
						<asp:HyperLink ID="hplItemName" runat="server"></asp:HyperLink>
					</ItemTemplate>
					<ItemStyle Width='12%' CssClass='text_list_links' HorizontalAlign='Left' />
				</asp:TemplateField>
				<asp:BoundField DataField='VendorCode' HeaderText='Vendor Code'>
					<ItemStyle Width='10%' />
				</asp:BoundField>
				<asp:BoundField DataField='VendorName' HeaderText='Vendor Name'>
					<ItemStyle Width='12%' />
				</asp:BoundField>
				<asp:BoundField DataField='Created' DataFormatString='{0:dd/MM/yyyy}' HeaderText='Created'>
					<ItemStyle Width='8%' />
				</asp:BoundField>


				<asp:TemplateField HeaderText='Expired'>
					<ItemTemplate>
						<asp:Label ID="lblExpired" runat="server"></asp:Label>
					</ItemTemplate>
					<ItemStyle Width='6%'  HorizontalAlign='Left' />
				</asp:TemplateField>



				<asp:TemplateField HeaderText='Status'>
					<ItemTemplate>
                        <asp:Label ID="lblStatus" runat="server"></asp:Label>
                    </ItemTemplate>
                    <ItemStyle  Width="6%" />
                </asp:TemplateField>

				<asp:TemplateField HeaderText='Translate' ItemStyle-CssClass="Abc" >

					<ItemTemplate>
						<asp:LinkButton ID="lnkbtnvn" runat="server" Text="VN" OnClick="lnkbtnVN_Click"
							CausesValidation='False'></asp:LinkButton>
						<asp:LinkButton ID="lnkbtnen" runat="server" Text="EN" OnClick="lnkbtnEN_Click"
							CausesValidation='False' Visible="false"></asp:LinkButton>
					</ItemTemplate>
					<ItemStyle CssClass="AdminDuyet" HorizontalAlign="Center" Width="8%" />
				</asp:TemplateField>

				<asp:TemplateField HeaderText='MSDS Online'>
					<ItemTemplate>
						<asp:LinkButton ID="lnkbtnViewvn" runat="server" Text="Translated" OnClick="lnkbtnViewVN_Click"
							CausesValidation='False'></asp:LinkButton> &nbsp;|&nbsp;
						<asp:LinkButton ID="lnkbtnViewen" runat="server" Text="Original MSDS" 
							CausesValidation='False'></asp:LinkButton>
					</ItemTemplate>
					<ItemStyle CssClass="GridTextLink" HorizontalAlign="Center" Width="12%" />
				</asp:TemplateField>


			</Columns>
			<HeaderStyle Height="26px" HorizontalAlign="Center" CssClass="GridHeader" />
			<RowStyle CssClass="GridRow" Height="23px" />
			<AlternatingRowStyle CssClass="GridAlterRow" />
			<PagerStyle CssClass="GridPaged" HorizontalAlign="Right" Height="23px" />
			<PagerSettings Mode="Numeric" PageButtonCount="2" />
			<EmptyDataRowStyle CssClass="GridTextEmpty" HorizontalAlign="Center" />
		</asp:GridView>
		<div style="clear: both; height: 5px">
		</div>
		<div>
			<asp:Button ID="btnDelete" CssClass="btn" runat="server" Text="Xóa" />
             <asp:Button ID="btnPublish" CssClass="btn btnChangeType" runat="server" Text="Chuyển Trạng Thái" />
              <asp:Button ID="btnExport" CssClass="btn" runat="server" Text="Export" CausesValidation="false"  PostBackUrl="~/Page/MSDS/List.aspx"/>
			<asp:Label ID="lblPage_Size" runat="server" Text="Số bản ghi trên trang:"></asp:Label>
			<asp:DropDownList ID="drpPage_Size" runat="server" AutoPostBack="True" Width="70px"
				CssClass="input_form">
				<asp:ListItem Text="10" Value="10"></asp:ListItem>
				<asp:ListItem Text="20" Value="20"></asp:ListItem>
				<asp:ListItem Text="50" Value="50"></asp:ListItem>
				<asp:ListItem Text="100" Value="100"></asp:ListItem>
                <asp:ListItem Text="200" Value="200"></asp:ListItem>
                <asp:ListItem Text="500" Value="500"></asp:ListItem>
			</asp:DropDownList>
			<asp:Label ID="lblTotal" runat="server"></asp:Label>
		</div>
		<div style="width: 100%">
			<!--phan trang-->
			<div id="results_resultsNavigationDiv" class="paginationEMP">
				<ul>
					<asp:LinkButton ID="lnkFirst" runat="server"></asp:LinkButton>
					<asp:Repeater ID="rptPage" runat="server">
						<ItemTemplate>
							<asp:LinkButton ID="lnkTitle" CssClass="page_num" runat="server" OnClick="lnkTitle_Click"></asp:LinkButton>
						</ItemTemplate>
					</asp:Repeater>
					<asp:LinkButton ID="lnkLast" runat="server"></asp:LinkButton>
				</ul>
			</div>
			<asp:HiddenField ID="hidCount" Value="0" runat="server" />
			<asp:HiddenField ID="hidIndex_page" Value="0" runat="server" />
			<asp:HiddenField ID="hidCur_Page" Value="1" runat="server" />
		</div>
		<div style='display: none'>
			<asp:DropDownList ID="drpMessage" runat="server">
				<asp:ListItem Text='Bạn có chắc chắn muốn xóa bản ghi này không?' Value='0'></asp:ListItem>
				<asp:ListItem Text='Bạn có chắc chắn muốn xóa bản đã chọn?' Value='1'></asp:ListItem>
				<asp:ListItem Text='Bạn phải chọn ít nhất một bản ghi.' Value='2'></asp:ListItem>
			</asp:DropDownList>
			<asp:HiddenField ID="hidID" Value="0" runat="server" />
            <asp:HiddenField ID="hidIsUser" Value="0" runat="server" />
            <iframe src="#" id="expFile">
    
            </iframe>
		</div>
	</ContentTemplate>
</asp:UpdatePanel>

